package com.asion.qkan.ui.fragment;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.Toast;

import com.asion.qkan.R;
import com.asion.qkan.adapters.NewAdapter;
import com.asion.qkan.entry.NewBean;
import com.asion.qkan.ui.contract.SheQuNewContract;
import com.asion.qkan.ui.model.SheQuNewModel;
import com.asion.qkan.ui.presenter.SheQuNewPresenter;

import butterknife.BindView;

/**
 * Created by Administrator on 2016/10/17 0017.
 */

public class SheQuNewFragment extends BaseFragment<SheQuNewPresenter,SheQuNewModel> implements SheQuNewContract.View {
    @BindView(R.id.new_recycler)
    RecyclerView recyclerView;
    private NewAdapter adapter;

    @Override
    protected int getLayoutResource() {
        return R.layout.fragment_she_qu_new;
    }

    @Override
    public void initPresenter() {
        mPresenter.setVM(this,mModel);
        mPresenter.setSheNewQuDatas(1);
    }

    @Override
    protected void initView() {
        adapter = new NewAdapter(getContext());
        recyclerView.setAdapter(adapter);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
        recyclerView.setLayoutManager(linearLayoutManager);
    }

    @Override
    public void showDataSuccess(NewBean.DataBean dataBean) {
        adapter.addAll(dataBean.getFeeds());
    }

    @Override
    public void showDataError(Throwable throwable) {
        Toast.makeText(getContext(),"请求失败",Toast.LENGTH_SHORT).show();
    }
}
